{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "33733e0b",
   "metadata": {},
   "source": [
    "## Regex Examples"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46c06d1e",
   "metadata": {},
   "source": [
    "### Example 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a704c5b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# joo select\n",
    "# koo select\n",
    "# loo select\n",
    "# woo\n",
    "# moo select\n",
    "# zoo\n",
    "# coo"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "254375c4",
   "metadata": {},
   "source": [
    "- Step 1: Write all the results separately you need"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cad1a8c",
   "metadata": {},
   "source": [
    "joo\n",
    "\n",
    "koo\n",
    "\n",
    "loo\n",
    "\n",
    "moo"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "27a22b60",
   "metadata": {},
   "source": [
    "- Step 2:Create imaginary line and separate them to find a pattern\n",
    "    - Usually we start creating lines whereever the similar pattern (like it happened with http and https) is breaking and then in end try to replicate each section by regex\n",
    "    (see the last example for refernce)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36b966a1",
   "metadata": {},
   "source": [
    "j|oo\n",
    "\n",
    "k|oo\n",
    "\n",
    "l|oo\n",
    "\n",
    "m|oo"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "746b5bc2",
   "metadata": {},
   "source": [
    "- Step 3: Write the expression"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0a25c34",
   "metadata": {},
   "source": [
    "- Pattern : [j-m]oo"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26c7adb4",
   "metadata": {},
   "source": [
    "### Example 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48582ab4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# xxx.yy select\n",
    "\n",
    "# xx.yyyy select\n",
    "\n",
    "# x.yy select\n",
    "\n",
    "# xy\n",
    "\n",
    "# xxyy\n",
    "\n",
    "# yyxx\n",
    "\n",
    "# yx\n",
    "\n",
    "# yxxx"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6345d86f",
   "metadata": {},
   "source": [
    "xxx|.|yy\n",
    "\n",
    "xx|.|yyyy\n",
    "\n",
    "x|.|yy"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e478b73c",
   "metadata": {},
   "source": [
    "- Pattern : x*\\.\\y*"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "964a50ba",
   "metadata": {},
   "source": [
    "### Example 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e4f78b0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# foobarbaz # select\n",
    "# foobazbcr # select\n",
    "# baazfobfd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f24912dc",
   "metadata": {},
   "source": [
    "foo|bar|baz\n",
    "\n",
    "foo|baz|bcr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8029b559",
   "metadata": {},
   "source": [
    "- \n",
    "Pattern : ^foo*"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d92503f4",
   "metadata": {},
   "source": [
    "### Example 4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60de94cd",
   "metadata": {},
   "source": [
    "foo|aaa|bar\n",
    "\n",
    "foo|a|bar\n",
    "\n",
    "foo|aa|bar"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d2961dd",
   "metadata": {},
   "source": [
    "- Pattern : fooa+bar # ^foo can also be used"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d847bdbf",
   "metadata": {},
   "source": [
    "### Example 5"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48adfa2f",
   "metadata": {},
   "source": [
    "http|s|:|//website\n",
    "    \n",
    "http|:|//website"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a628fb97",
   "metadata": {},
   "source": [
    "- Pattern : https?://website"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}